<?php
/* TODO: Add code here */
require('config/globalconfig.php');
?>
<?php
include_once('classes/user_sphinx_search.php');
include_once('classes/user_product.php');
include_once('classes/user_property.php');
include_once('classes/user_catalogue.php');
include_once('classes/user_faq.php');
include_once('classes/user_section.php');
include_once('classes/user_manufactory.php');
//user_common::writeLog('insert',0);
$objProduct = new user_product($objConnection);
$objProperty = new user_property($objConnection);
$objFAQ = new user_faq($objConnection);
//$_SESSION[user_common::SES_C_USERINFO] = "user";
//$_SESSION[user_common::SES_C_USERINFO]["active"]=1;
//$objProduct->insert('1','1','1','1');
if ($_pgR["act"]==user_product::ACT_ADD)
{
	if (user_common::isCLogin())
	{
		/*
		//lấy thông tin user
		//$c_userInfo = $_SESSION[consts::SES_C_USERINFO];
		
		$strProperty = $_pgR['property'];
		$arrProperty = explode(user_common::STRING_SEPARATE_1,$strProperty);
		//print_r($arrProperty);
		$strNameProperty = $arrProperty[0];
		$strValueProperty = $arrProperty[1];
		
		$resultID = $objProduct->insert($_pgR['manu'],$_pgR['cat'],user_common::formatOutputText($_pgR['name']));
		$objProperty->insertPropertyBatch($resultID,$_pgR['cat'],'1', $strNameProperty,$strValueProperty) ;
		
		//thêm phần bang cau hoi
		$strFAQ = $_pgR['faq'];
		$arrFAQ = explode(user_common::STRING_SEPARATE_1,$strFAQ);
		//print_r($arrProperty);
		$strQuestion = $arrFAQ[0];
		$strAnswer = $arrFAQ[1];
		
		$objFAQ->insertFaqBatch($resultID,'1', $strQuestion,$strAnswer) ;
		if ($resultID)
		{
			$arrHeader = user_common::getMessageHeaderArr($banCode);//$banCode
			//echo $strHeaderMessage."1".consts::SEP_RESPONSE.$strResultHTML.consts::SEP_RETURN.$_pgR["ontop"];
			echo user_common::convertToXML(
					$arrHeader, array("rs", "inf"), 
					array(1, $result ), 
					array( 0, 1 )
					);
			return;
		}
		*/
	}
	echo user_common::convertToXML($arrHeader, array("rs"), array(0), array(0));
	return;
}
elseif($_pgR['act'] == user_product::ACT_CHANGE_PAGE)
{
	$intPage = $_pgR['p'];
	
	$outPutHTML =  $objProduct->getListProduct($intPage);
	echo user_common::convertToXML($strMessageHeader, array('rs','inf'), array(1,$outPutHTML),array(0,1));
	return ;
}

//output chi tiet san pham: tinh nang, cau hoi faq
if(isset($_pgR['product']) && isset($_pgR['cat']))
{
	$product_id = $_pgR['product'];
	$cat_id = $_pgR['cat'];
	//if(!$cat_id)
	//{
		
		//print_r($arrProduct);
		$cat_id = $arrProduct['cat_id'];
		//echo $cat_id;
	//}
	$strHTMLProduct = $objProduct->outputHTMLProductDetail($product_id,$cat_id);
}

// echo 'callcenter';
// user_common::writeLog("anc",1);


include_once('include/_header.inc');
include_once('include/_menu.inc');
include_once('include/_search_box_detail.inc');
?>
<script type="text/javascript" src="<?php echo $_objSystem->locateJs('user_admin_product.js');?>"></script>
<script type="text/javascript" src="<?php echo $_objSystem->locateJs('ajaxupload.js');?>"></script>
	
<!--Begin Form Input -->
<input type="hidden" id="adddocmode" name="adddocmode" value="1<?php //echo $intMode;?>" />
<input type="hidden" id="txtPage" name="txtPage" value="<?php echo $_pgR["p"]?$intPage:1;?>" />
 
<?php 
//echo '<br><h2 align="center">Sản phẩm: ' .$arrProduct['name'].'</h2>';
//output chi tiet san pham
echo '<div align="center">' .$strHTMLProduct.'</div>';
?>
		<!--div>
			<div style="float:left;width:49%;">
				<table class="tbl-list" style="width:100%">
					<thead>
						<td class="lastCell" colspan="2">Tính năng riêng</td>
					</thead>
					<tr class="even">
					<td>Tinh nang</td>
							<td class="lastCell"> gia tri tinh nang</td>
					</tr>
					 <tr  class="odd">
					<td>Tinh nang</td>
							<td class="lastCell"> gia tri tinh nang</td>
					</tr>
				</table>
			</div>
			<div style="float:right;width:49%; ">
				<table  class="tbl-list" style="width:100%">
					<thead>
					<td colspan="2" class="lastCell">Tính năng riêng chung</td>
				</thead>
					<tr class="even">
						<td>Tinh nang</td>
						<td class="lastCell"> gia tri tinh nang</td>
					</tr>
					 <tr  class="odd">
						<td>Tinh nang</td>
						<td class="lastCell"> gia tri tinh nang</td>
					</tr>
				</table>
			</div>
       </div>
       
        <div style="padding-top:100px">
			<div style="float:left;width:49%;">
				<table class="tbl-list" style="width:100%">
				<thead>
					<td class="lastCell">Câu hỏi riêng</td>
				</thead>
				<tr class="even">
				<td class="lastCell">Tinh nang</td>
		               
				</tr>
				 <tr  class="odd">
				<td class="lastCell">Tinh nang</td>
		         
				</tr>
	       
			</table>
			</div>
			<div style="float:right;width:49%;">
				<table  class="tbl-list" style="width:100%">
				<thead>
						<td class="lastCell">Câu hỏi chung</td>
				</thead>
				<tr class="even">
				<td class="lastCell">Câu hỏi</td>
		         
				</tr>
				 <tr  class="odd">
				<td class="lastCell">Câu đáp</td>
		           
				</tr>
		       
			   <tr class="even">
				<td class="lastCell">Câu hỏi</td>
		         
				</tr>
				 <tr  class="odd">
				<td class="lastCell">Câu đáp</td>
		           
				</tr> <tr class="even">
				<td  class="lastCell">Câu hỏi</td>
		         
				</tr>
				 <tr  class="odd">
				<td  class="lastCell">Câu đáp</td>
		           
				</tr> <tr class="even">
				<td  class="lastCell">Câu hỏi</td>
		         
				</tr>
				 <tr  class="odd">
				<td  class="lastCell">Câu đáp</td>
		           
				</tr>
				</table>
			</div>
       </div-->


<?php 
//footer
include_once('include/_footer.inc');
?>